import React from 'react';
import SingleInput from './singleInput'; //单行输入
import SingleSelect from './singleSelect'; //单项选择
import MultiSelect from './multiSelect'; //多项选择
import DatePicker from './datePicker'; //日期选择
import DateRangePicker from './dateRange'; //时间范围选择
import Cascader from './cascader'; //级联选择
import Radio from './radio'; //级联选择

const ControlUI = new Map();

ControlUI.set('text', SingleInput);
ControlUI.set('input', SingleInput);
ControlUI.set('textarea', SingleInput);
ControlUI.set('select', SingleSelect);
ControlUI.set('multiSelect', MultiSelect);
ControlUI.set('date', DatePicker);
ControlUI.set('dateRange', DateRangePicker);
ControlUI.set('cascader', Cascader);
ControlUI.set('radio', Radio);

export default class ControlFactory {
  static getControlComponent(uiCode = 'input', args) {
    if (ControlUI.has(uiCode)) {
      return React.createElement(ControlUI.get(uiCode), { ...args });
    }
    return <>开发中</>;
  }
}
